package com.jxau.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxau.dao.MovieDao;
import com.jxau.domain.Movie;
import com.jxau.service.MovieService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class MovieServiceImpl extends ServiceImpl<MovieDao, Movie> implements MovieService {
    @Resource
    private MovieDao movieDao;

    @Override
    public IPage<Movie> getPage(int currentPage, int pageSize, Movie movie) {
        QueryWrapper<Movie> qw = new QueryWrapper<Movie>();
        if(!movie.getMovietitle().equals("")){
            qw.eq("movietitle", movie.getMovietitle());
        }
        if(movie.getMovieid() != null){
            qw.eq("movieid", movie.getMovieid());
        }
        IPage<Movie> page = new Page<Movie>(currentPage,pageSize);
        movieDao.selectPage(page,qw);
        return page;
    }
}
